﻿using System;
using Faml;
using Faml.Compiler;
using Faml.Frontend;

public class WriteCommand : ExternalCommand
{
    public WriteCommand() : base("write")
        { /* Nothing to do here */ }

    public override void Parse(Parser parser, RuntimeEnvironment runtime)
    {
        while (true)
        {
            PrintHelper.Print(FamlProgram.Evaluate(runtime, runtime.Precompile(parser)));
            if (parser.MatchDelimiter(";")) {
                parser.MoveNext();
                break;
            } else if(parser.MatchDelimiter(","))
                parser.MoveNext();
            else
                throw new Exception("Syntax error in write command");
        }
    }
}